<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><fmt:message code="global.lang.Edit" /></title>
    <%--<fmt:message code="global.page.first" />--%>
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta http-equiv="Content-Type" content="text/html;">
    <meta name="viewport"
          content="width=device-width, initial-scale=0.3, user-scalable=0, minimum-scale=0, maximum-scale=5.0,user-scalable=yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.tag.css">
    <link rel="stylesheet" type="text/css" href="../css/address/new_add.css" />
    <script type="text/javascript" src="../js/utility.js"></script>
    <link rel="stylesheet" type="text/css" href="../../lib/laydate.css"/>
    <script type="text/javascript" src="../js/attach.js"></script>
    <script src="../js/module.js"></script>
    <script src="../js/mouse_mon.js"></script>
    <script src="../js/wdatepicker.js"></script>
    <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>

<%--<script src="../js/jquery/jquery.min.js"></script>--%>
    <script src="../../lib/laydate/laydate.js"></script>
    <script src="../js/bootstrap/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/base/base.js"></script>
    <script>
        var param = $.GetRequest();
        $(function(){
            //初始化联系人信息
            $.ajax({
                type: "get",
                url: "/user/getUserByuid",
                data: param,
                success: function (res) {
                    if (res.msg="OK") {
                        var data = res.object;
                        $("#uid").val(data.uid)
                        $("#userName").val(data.userName);
                        $("#sex").val(data.sex);
                        $("#mobilNo").val(data.mobilNo);
                        $("#telNoDept").val(data.telNoDept);
                        $("#deptName").val(data.deptName);
                        $("#roomNum").val(data.roomNum);
                        $("#ministration").val(data.ministration);
                        $("#faxNoDept").val(data.faxNoDept);

                    }
                }
            })
        })
    </script>
    <script>
        function IsNumber(str)
        {
            return str.match(/^[0-9]*$/)!=null;
        }

        function CheckPostOffice(str) {
            return str.match(/^[1-9][0-9]{5}$/)!=null;
        }

        function CheckPhone(str) {
            return str.match(/^1[34578]\d{9}$/)!=null;
        }

        function CheckFax(str) {
            return str.match( /^(\d{3,4}-)?\d{7,8}$/)!=null;
        }

        function IsValidEmail(str)
        {
            var re = /@/;
            return str.match(re)!=null;
        }
        function CheckForm()
        {
            if(document.form1.userName.value=="")
            {
                alert("<fmt:message code="hr.th.empty" />");
                return (false);
            }
            <%--if(document.form1.email.value!="" && !IsValidEmail(document.form1.email.value))--%>
            <%--{--%>
                <%--alert("<fmt:message code="hr.th.mailbox" />");--%>
                <%--return (false);--%>
            <%--}--%>
            if(document.form1.mobilNo.value!=""&&!CheckPhone(document.form1.mobilNo.value))
            {
                alert("请输入正确的手机号！");
                return (false);
            }
            if(document.form1.faxNoDept.value!=""&&!CheckFax(document.form1.faxNoDept.value)){
                alert("请输入正确的传真！")
                return (false);
        }

//            document.form1.submit();
            var formData = new FormData($("form")[0]);
            $.ajax({
                type: "post",
                url: "/user/edit",
                data: formData,
                processData:false,
                contentType:false,
                success: function(res){
                    if(res.msg=="OK"){
                        alert("<fmt:message code="depatement.th.Modifysuccessfully" />");
                        parent.location.reload();
                    }else{
                        alert("<fmt:message code="depatement.th.modifyfailed" />！\n"+res.message);
                    }
                }
            })
        }

        function show_hidden(show_id)
        {
            $('#'+show_id+'_div').show();
        }

        function hide_div(show_id)
        {
            $('#'+show_id).val("");
            $('#'+show_id+'_div').hide();
        }
        function hide_show(group_id)
        {
            var all_public = $('#public_group_id_str').val();
            var all_public_arr = all_public.split(",");
            if($.inArray(group_id, all_public_arr) > -1)
            {
                $('#share').hide();
                $('#show_share').hide();
            }
            else
            {
                $('#share').show();
            }
        }
    </script>
</head>
<body>
<div class="new_f">
    <form enctype="multipart/form-data" action="edit_update.php"  method="post" name="form1" id="form1" class="form-horizontal" onSubmit="return CheckForm();" style="margin: 0px;">
     <%--   <div class="left" style="width: 220px;height: 400px;">
            <div id="img">
                <img src="" style="width:170px;height:175px"/>
            </div>
            <div id="left_bts">
                <button type="button" class="btn btn-success" style="width:80px;margin-right: 3px;margin-bottom:5px;" id="upload" onClick="photo.click()" title="<fmt:message code="url.th.format" />"><i class="icon-arrow-up icon-white"></i><fmt:message code="global.th.upload" /></button>
                <button type="button" class="btn btn-danger" style="width:80px;margin-right: 0px;margin-bottom:5px;" id="clear" onClick="clear_photo()"><i class="icon-remove icon-white"></i><fmt:message code="notice.th.delete1" /></button><br />
                <input type='file' id="photo" name="ATTACHMENT" style="cursor:pointer; position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:100px" size='1'  hideFocus='' title="<fmt:message code="url.th.format" />"/><!-- onChange="previewImg(this.value);"-->
            </div>
        </div>--%>
        <input type="hidden" id="uid" name="uid"/>
        <div class="right" id="show_right" style="width:100%;">
            <div id="name">
                <div class="control-group" style="margin-top:20px;">
                    <label class="control-label" for="userName"><fmt:message code="userDetails.th.name" />：</label>
                    <div class="controls" style="position:relative;">
                        <input type="text" id="userName" name="userName" style="width: 180px;" value=""><span class="red">&nbsp;&nbsp;<fmt:message code="userDetails.th.required" /></span>
                    </div>
                </div>

                <div id="sex_div" class="control-group" style="width:480px;">
                    <label class="control-label" for="sex"><fmt:message code="userDetails.th.Gender" />：</label>
                    <div class="controls">
                        <select name="sex" id="sex" class="input-large" style="width: 135px;">
                            <option value="" >请选择</option>
                            <option value="0"><fmt:message code="userInfor.th.male" /></option>
                            <option value="1"><fmt:message code="userInfor.th.female" /></option>
                        </select>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="mobilNo"><fmt:message code="userDetails.th.mobilePhone" />：</label>
                    <div class="controls">
                        <input type="text" id="mobilNo" name="mobilNo" value=""  style="width: 180px;">
                    </div>
                </div>

                <div id="tel_no_dept_div" class="control-group" style="width:480px;">
                    <label class="control-label" for="telNoDept"><fmt:message code="depatement.th.phone" />：</label>
                    <div class="controls">
                        <input type="text" id="telNoDept" name="telNoDept" value="" style="width: 180px;">
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="deptName"><fmt:message code="depatement.th.Company" />：</label>
                    <div class="controls">
                        <input type="text" id="deptName" name="deptName" value="" style="width: 180px;">
                    </div>
                </div>

                <div class="control-group" style="margin-top:20px;">
                    <label class="control-label" for="roomNum">房间号：</label>
                    <div class="controls" style="position:relative;">
                        <input type="text" id="roomNum" name="roomNum" style="width: 180px;" value="">
                    </div>
                </div>

                <%--<div class="control-group" style="margin-top:20px;">--%>
                    <%--<label class="control-label" for="ministration">职务：</label>--%>
                    <%--<div class="controls" style="position:relative;">--%>
                        <%--<input type="text" id="ministration" name="ministration" style="width: 180px;" value="">--%>
                    <%--</div>--%>
                <%--</div>--%>

                <div  class="control-group" style="width:480px;">
                    <label class="control-label" for="faxNoDept"><fmt:message code="url.th.Workfax" />：</label>
                    <div class="controls">
                        <input type="text" id="faxNoDept" name="faxNoDept" value="" style="width: 180px;">
                    </div>
                </div>
            </div>

            <input type="hidden" name="add_input_count" id="add_input_count" value="0">
            <input type="hidden" name="add_id" id="add_id" value="">
            <input type="hidden" name="attachment_id_old" value="">
            <input type="hidden" name="attachment_name_old" value="">
        </div>
        <input type="hidden" name="public_group_id_str" id="public_group_id_str" value="">
    </form>
</div>
</body>
</html>